Open the project in your IDE, and then open the index.ts file. For example, if using Visual Studio Code:
bash
Copy
Ask AI
code .
4
In line 14 of the index.ts file, replace ‘YOUR_APP_ID’ and ‘YOUR_TOKEN’ with your app ID and playground token. (See Getting SDK Connection Details)
JS
Copy
Ask AI
await init();const ditto = new Ditto({ type: "onlinePlayground", appID: "REPLACE_ME_WITH_YOUR_APP_ID", token: "REPLACE_ME_WITH_YOUR_PLAYGROUND_TOKEN", customAuthURL: "REPLACE_ME_WITH_YOUR_AUTH_URL", enableDittoCloudSync: false, // This is required to be set to false to use the correct URLs});ditto.updateTransportConfig((config) => { config.connect.websocketURLs.push( 'wss://REPLACE_ME_WITH_YOUR_WEBSOCKET_URL' );});// Disable DQL strict mode so that collection definitions are not required in DQL queriesawait ditto.store.execute("ALTER SYSTEM SET DQL_STRICT_MODE = false");ditto.startSync();
5
Build the demo task app:
bash
Copy
Ask AI
npm run build
6
Interact with the demo task app and simulate real-time peer-to-peer replication by running the demo task app in two or more separate terminals (one for each small peer):
bash
Copy
Ask AI
node index.js
7
Using the commands that automatically appear in each of your terminals, add, remove, and modify documents as desired.
8
If you want to observe your changes sync with the cloud-optional deployment, the Big Peer, open the data browser in the Ditto portal.